package com.jay.math.clazz;

import java.math.BigDecimal;
import java.math.RoundingMode;

public class BigDecimalCls {
	public static void main(String[] args) {
		double d1 = 1.234d;
		double d2 = 9.8765d;

		BigDecimal bd1 = new BigDecimal(d1);
		BigDecimal bd2 = new BigDecimal(d2);
		BigDecimal bd3 = new BigDecimal(12);

		System.out.println("-----------------------");
		System.out.println("byteValue: " + bd1.byteValue());
		System.out.println("byteValueExact: " + bd3.byteValueExact());
		System.out.println("compareTo: " + bd1.compareTo(bd2));
		System.out.println("doubleValue: " + bd1.doubleValue());
		System.out.println("floatValue: " + bd1.floatValue());
		System.out.println("hashCode: " + bd1.hashCode());
		System.out.println("intValue: " + bd1.intValue());
		System.out.println("intValueExact: " + bd3.intValueExact());
		System.out.println("longValue: " + bd1.longValue());
		System.out.println("longValueExact: " + bd3.longValueExact());
		System.out.println("-----------------------");
		System.out.println("precision: " + bd1.precision());
		System.out.println("scale: " + bd1.scale());
		System.out.println("shortValue: " + bd1.shortValue());
		System.out.println("shortValueExact: " + bd3.shortValueExact());
		System.out.println("signum: " + bd1.signum());
		System.out.println("scaleByPowerOfTen: " + bd1.scaleByPowerOfTen(2));
		System.out.println("setScale: " + bd3.setScale(2));
		System.out.println("setScale2: "
				+ bd1.setScale(2, RoundingMode.CEILING));
		System.out.println("-----------------------");
		System.out.println("stripTrailingZeros: " + bd1.stripTrailingZeros());
		System.out.println("subtract: " + bd1.subtract(bd2));
		System.out.println("toEngineeringString: " + bd1.toEngineeringString());
		System.out.println("toPlainString: " + bd1.toPlainString());
		System.out.println("toBigInteger: " + bd1.toBigInteger());
		System.out.println("toBigIntegerExact: " + bd3.toBigIntegerExact());
		System.out.println("abs: " + bd1.abs());
		System.out.println("add: " + bd1.add(bd2));
		System.out.println("divide: " + bd1.divide(bd2, RoundingMode.DOWN));
		System.out.println("-----------------------");
		System.out.println("equals: " + bd1.equals(bd3));
		System.out.println("movePointLeft: " + bd1.movePointLeft(1));
		System.out.println("multiply: " + bd1.multiply(bd2));
		System.out.println("negate: " + bd1.negate());
		System.out.println("plus: " + bd1.plus());
		System.out.println("pow: " + bd1.pow(2));
		System.out.println("remainder: " + bd1.remainder(bd3));
		System.out.println("ulp: " + bd1.ulp());
		System.out.println("unscaledValue: " + bd1.unscaledValue());
		System.out.println("-----------------------");
		System.out.println("valueOf: " + BigDecimal.valueOf(9.999));
		System.out.println("valueOf: " + BigDecimal.valueOf(123l));
		System.out.println("valueOf: " + BigDecimal.valueOf(876, 3));
	}
}
